package com.example.peanutsubway.service.impl;

import com.example.peanutsubway.dao.impl.GameDaoImpl;
import com.example.peanutsubway.entity.Game;
import com.example.peanutsubway.entity.PageInfo;
import com.example.peanutsubway.service.GameService;
import com.example.peanutsubway.vo.GameType;

import java.util.List;

/**
 * @Author：liyangsong
 * @Version：1.0
 * @Date：2021/10/10-20:22
 * @Since:jdk1.8
 * @Description:
 */


public class GameServiceImpl implements GameService {
    private GameDaoImpl gameDao = new GameDaoImpl();

    /**
     * 分页查询游戏
     *
     * @param game
     * @param nowPage
     * @param pageNum
     * @return
     */
    @Override
    public PageInfo showAllGame(Game game, String nowPage, String pageNum) {
        Integer count = gameDao.count(game); // 游戏数量
        PageInfo page = new PageInfo(nowPage, pageNum, count);
        List<GameType> gameTypes = gameDao.showAllGame(game, page);
//        for (GameTypeInfo gameType : gameTypes) {
//            GameUtils.getGameState(gameType.getGameState());
//            GameUtils.getPlatform(gameType.getGamePlatform());
//        }
        page.setDataList(gameTypes);
        return page;
    }

    /**
     * 添加游戏
     *
     * @param game
     * @return
     */
    @Override
    public Boolean addGame(Game game) {
        return gameDao.addGame(game);
    }

    @Override
    public Boolean updateGame(Game game) {
        return gameDao.updateGame(game);
    }

    @Override
    public Boolean deleteGame(Integer gid) {

        return gameDao.deleteGame(gid);
    }


    @Override
    public List<Game> iosUrlList(Game game) {

        return gameDao.iosUrlList(game);
    }

    @Override
    public List<Game> androidUrlList(Game game) {

        return gameDao.androidUrlList(game);
    }

    @Override
    public List<Game> gameiconUrlList(Game game) {
        return gameDao.gameiconUrlList(game);
    }

    @Override
    public List<Game> gamepictureList(Game game) {
        return gameDao.gamepictureList(game);
    }

}
